<?php 
include_once 'root.php';
Class Helpdesk extends Root{
	public function __construct(){
		parent::__construct();
		$this->load->helper("util");
	}
	public function index(){
		$this->data['header']= "Send Email to IT";
		$this->includeView("helpdesk");
	}
	public function sendEmail(){
		$data = $this->Post2Array($_POST);
		
		foreach($data as $in=>$val){
			if($val==""){
				echo json_encode(array("flag"=>false,"message"=>"กรุณากรอกข้อมูลให้ครบถ้วน"));
				exit();
			}
		}
		
		/*
		$data['firstname'] = "supachai";
		$data['lastname'] = "somrit";
		$data['email'] = "dy_zildjian@hotmail.com";
		$data['telephone'] = "0866605525";
		$data['description'] = "description";
		*/
		$message = htmlContent($data);
		$send = send_mail("senzitivegalz@gmail.com", "email helpdesk", $message);
		if($send){
			echo json_encode(array("flag"=>true));
		}else{
			echo json_encode(array("flag"=>false));
		}
		exit();
	}
	
	
}
?>